﻿namespace RESTController.Lib
{
    internal class PageCountCalculator
    {
        public static int CalculateNumberOfPages(int pageSize, int totalCount)
        {
            Check.ArgumentFollowsRule(pageSize, i => i > 0, "Page Size must be greater than 0.");

            if (pageSize > 0 && totalCount > pageSize)
            {
                int totalPages = totalCount / pageSize;
                if (totalCount % pageSize > 0)
                {
                    totalPages += 1;
                }
                return totalPages;
            }
            return 1;
        }
    }
}
